import { MyInterface } from '../lib/interface';
import { MyClass } from '../lib/class';

let message: string = 'Hello, 安德斯·海尔斯伯格(Anders Hejlsberg)!';
console.log(message);
console.log("USER:%s, FLAG:%s", process.env.USER, process.env.FLAG)
process.env.FLAG = "TypeScript"
console.log("USER:%s, FLAG:%s", process.env.USER, process.env.FLAG)
// -----------------------------------------------
// type declaration (good)
const ir1: MyInterface.Rectangle = {
  kind: 'rectangle',
  height: 10,
  width: 20
}
// type assertion (bad)
const ir2 = { kind: 'square', width: 15 } as MyInterface.Square
console.log(MyInterface.calculateArea(ir1))
console.log(MyInterface.calculateArea(ir2))

// -----------------------------------------------
const cr = new MyClass.Rectangle(20, 10)
console.log(MyClass.calculateArea(cr))

// -----------------------------------------------
// How Context Is Used in Type Inference
type Language = 'JavaScript' | 'TypeScript' | 'Python';
function setLanguage(language: Language) { /* ... */ }

// let language = 'JavaScript';
let language: Language = 'JavaScript';
setLanguage(language);
const language2 = 'TypeScript';
setLanguage(language2);